﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using DirectShowLib;

namespace DxSnap
{
	public partial class ChooseDvc : Form
	{
		public ChooseDvc()
		{
			InitializeComponent();
		}

		private void ChooseDvc_Load(object sender, EventArgs e)
		{
			foreach (DsDevice ds in DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice))
			{
				this.listBox1.Items.Add(ds.Name);
			}
		}

		private void listBox1_DoubleClick(object sender, EventArgs e)
		{
			if (this.listBox1.SelectedIndex > -1)
			{
				DeviceSettings.Default.VIDEODEVICE = this.listBox1.SelectedIndex;
				DeviceSettings.Default.Save();
				this.DialogResult = DialogResult.OK;
			}
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (this.listBox1.SelectedIndex > -1)
			{
				DeviceSettings.Default.VIDEODEVICE = this.listBox1.SelectedIndex;
				DeviceSettings.Default.Save();
				this.DialogResult = DialogResult.OK;
			}
			else
			{
				MessageBox.Show("请选择一个设备!");
			}
		}
	}
}
